package com.chance.cc.crawler.development.command.meta.keyword.gome;

import com.chance.cc.crawler.development.command.meta.keyword.CrawlerDomainKeywordCommand;
import com.chance.cc.crawler.meta.core.bean.crawler.CrawlerDomainKeys;
import org.apache.commons.lang3.StringUtils;

import java.io.*;

/**
 * @ClassName gome
 * @Description TODO
 * @Author songding
 * @Date 2021/10/21 13:01
 * @Version 1.0
 **/
public class GomeKeywords {
    private static final String domain = "gome";
    private static final String site = "SearchKV";
    private static final String HOST = "192.168.1.217";
    private static final int PORT = 9599;

    public static void main(String[] args) throws IOException {
        String path = "F:\\changxi\\chance-crawler-development2\\crawler-scripts-command\\src\\main\\java\\com\\chance\\cc\\crawler\\development\\command\\meta\\keyword\\gome\\search.txt";
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(new File(path)), "UTF-8"));
        String lineData = null;
        while ((lineData = bufferedReader.readLine()) != null){
            if(StringUtils.isBlank(lineData)){
                continue;
            }
            CrawlerDomainKeywordCommand crawlerDomainKeywordCommand = new CrawlerDomainKeywordCommand(HOST,PORT);

            CrawlerDomainKeys crawlerDomainKeys = new CrawlerDomainKeys();
            crawlerDomainKeys.setDomain(domain);
            crawlerDomainKeys.setSite(site);
            crawlerDomainKeys.setKeyword(lineData);
            crawlerDomainKeys.setStatus(0);
            crawlerDomainKeywordCommand.addOrUpdateKeys(crawlerDomainKeys);
            //crawlerDomainKeywordCommand.delKeys(crawlerDomainKeys);
            //http://192.168.1.217:9599/v1/meta/gome/keys?site=SearchKV
            System.out.println(lineData);
        }

    }

}
